Dynomotion

Group: DynoMotion Message: 10258 From: adatesman Date: 10/6/2014
Subject: I did something stupid, and now it doesn't work

I hate giving up when it's likely a programming error on my part, but it was working a couple days ago and now is not.


And by "working" I mean I had just finished tweaking the V, Accel, and Jerk settings on my Taig to be where they should be for best performance under KmotionCNC (thinking of giving Mach3 the boot) and everything was working just fine, but not it doesn't.  As in GCode positions commanded in Kmotion and KmotionCNC don't do anything.  Oddly, the homing sequence I just finished tweaking works just fine, as does jogging both with the screen buttons and with the keyboard.

What stupid thing am I missing?  No difference if I run it in Kmotion or KmotionCNC, and a MoveAtVel command works just fine from the console.  Clearly I switched something somewhere, but damned if I can find it. 

Running V4.32, and here are my INIT and Homing programs:

INIT (Thread1)
#include "KMotionDef.h"

main()
#define X 0
#define Y 1
#define Z 2

{
    DefineCoordSystem(0,1,2,-1);
    FPGA(STEP_PULSE_LENGTH_ADD)=32 + 0x80;
    EnableAxisDest(0,0);
    EnableAxisDest(1,0);
    EnableAxisDest(2,0);


    ch0->InputMode=NO_INPUT_MODE;
    ch0->OutputMode=STEP_DIR_MODE;
    ch0->Vel=73333;
    ch0->Accel=7e+006;
    ch0->Jerk=2e+007;
    ch0->P=1;
    ch0->I=0;
    ch0->D=0;
    ch0->FFAccel=0;
    ch0->FFVel=0;
    ch0->MaxI=200;
    ch0->MaxErr=200;
    ch0->MaxOutput=200;
    ch0->DeadBandGain=1;
    ch0->DeadBandRange=0;
    ch0->InputChan0=0;
    ch0->InputChan1=1;
    ch0->OutputChan0=8;
    ch0->OutputChan1=1;
    ch0->MasterAxis=-1;
    ch0->LimitSwitchOptions=0x113;
    ch0->LimitSwitchNegBit=0;
    ch0->LimitSwitchPosBit=0;
    ch0->SoftLimitPos=440000;
    ch0->SoftLimitNeg=-2000;
    ch0->InputGain0=1;
    ch0->InputGain1=1;
    ch0->InputOffset0=0;
    ch0->InputOffset1=0;
    ch0->OutputGain=-1;
    ch0->OutputOffset=0;
    ch0->SlaveGain=1;
    ch0->BacklashMode=BACKLASH_OFF;
    ch0->BacklashAmount=0;
    ch0->BacklashRate=0;
    ch0->invDistPerCycle=1;
    ch0->Lead=0;
    ch0->MaxFollowingError=1000000000;
    ch0->StepperAmplitude=250;

    ch0->iir[0].B0=1;
    ch0->iir[0].B1=0;
    ch0->iir[0].B2=0;
    ch0->iir[0].A1=0;
    ch0->iir[0].A2=0;

    ch0->iir[1].B0=1;
    ch0->iir[1].B1=0;
    ch0->iir[1].B2=0;
    ch0->iir[1].A1=0;
    ch0->iir[1].A2=0;

    ch0->iir[2].B0=1;
    ch0->iir[2].B1=0;
    ch0->iir[2].B2=0;
    ch0->iir[2].A1=0;
    ch0->iir[2].A2=0;

   
    ch1->InputMode=NO_INPUT_MODE;
    ch1->OutputMode=STEP_DIR_MODE;
    ch1->Vel=70000;
    ch1->Accel=7e+006;
    ch1->Jerk=2e+007;
    ch1->P=1;
    ch1->I=0;
    ch1->D=0;
    ch1->FFAccel=0;
    ch1->FFVel=0;
    ch1->MaxI=200;
    ch1->MaxErr=200;
    ch1->MaxOutput=200;
    ch1->DeadBandGain=1;
    ch1->DeadBandRange=0;
    ch1->InputChan0=1;
    ch1->InputChan1=2;
    ch1->OutputChan0=9;
    ch1->OutputChan1=3;
    ch1->MasterAxis=-1;
    ch1->LimitSwitchOptions=0x11a;
    ch1->LimitSwitchNegBit=1;
    ch1->LimitSwitchPosBit=1;
    ch1->SoftLimitPos=200000;
    ch1->SoftLimitNeg=-2000;
    ch1->InputGain0=1;
    ch1->InputGain1=1;
    ch1->InputOffset0=0;
    ch1->InputOffset1=0;
    ch1->OutputGain=-1;
    ch1->OutputOffset=0;
    ch1->SlaveGain=1;
    ch1->BacklashMode=BACKLASH_OFF;
    ch1->BacklashAmount=0;
    ch1->BacklashRate=0;
    ch1->invDistPerCycle=1;
    ch1->Lead=0;
    ch1->MaxFollowingError=1000000000;
    ch1->StepperAmplitude=250;

    ch1->iir[0].B0=1;
    ch1->iir[0].B1=0;
    ch1->iir[0].B2=0;
    ch1->iir[0].A1=0;
    ch1->iir[0].A2=0;

    ch1->iir[1].B0=1;
    ch1->iir[1].B1=0;
    ch1->iir[1].B2=0;
    ch1->iir[1].A1=0;
    ch1->iir[1].A2=0;

    ch1->iir[2].B0=1;
    ch1->iir[2].B1=0;
    ch1->iir[2].B2=0;
    ch1->iir[2].A1=0;
    ch1->iir[2].A2=0;


    ch2->InputMode=NO_INPUT_MODE;
    ch2->OutputMode=STEP_DIR_MODE;
    ch2->Vel=70000;
    ch2->Accel=7e+006;
    ch2->Jerk=2e+007;
    ch2->P=1;
    ch2->I=0;
    ch2->D=0;
    ch2->FFAccel=0;
    ch2->FFVel=0;
    ch2->MaxI=200;
    ch2->MaxErr=200;
    ch2->MaxOutput=200;
    ch2->DeadBandGain=1;
    ch2->DeadBandRange=0;
    ch2->InputChan0=2;
    ch2->InputChan1=3;
    ch2->OutputChan0=10;
    ch2->OutputChan1=5;
    ch2->MasterAxis=-1;
    ch2->LimitSwitchOptions=0x113;
    ch2->LimitSwitchNegBit=2;
    ch2->LimitSwitchPosBit=2;
    ch2->SoftLimitPos=2000;
    ch2->SoftLimitNeg=-240000;
    ch2->InputGain0=1;
    ch2->InputGain1=1;
    ch2->InputOffset0=0;
    ch2->InputOffset1=0;
    ch2->OutputGain=1;
    ch2->OutputOffset=0;
    ch2->SlaveGain=1;
    ch2->BacklashMode=BACKLASH_OFF;
    ch2->BacklashAmount=0;
    ch2->BacklashRate=0;
    ch2->invDistPerCycle=1;
    ch2->Lead=0;
    ch2->MaxFollowingError=1000000000;
    ch2->StepperAmplitude=250;

    ch2->iir[0].B0=1;
    ch2->iir[0].B1=0;
    ch2->iir[0].B2=0;
    ch2->iir[0].A1=0;
    ch2->iir[0].A2=0;

    ch2->iir[1].B0=1;
    ch2->iir[1].B1=0;
    ch2->iir[1].B2=0;
    ch2->iir[1].A1=0;
    ch2->iir[1].A2=0;

    ch2->iir[2].B0=1;
    ch2->iir[2].B1=0;
    ch2->iir[2].B2=0;
    ch2->iir[2].A1=0;
    ch2->iir[2].A2=0;


Homing (Thread2):
#include "KMotionDef.h"

main()
{
    int SaveLimits;

{   
        // Home Z - jog until it sees the limit
        SaveLimits = ch2->LimitSwitchOptions; // save original limit settings
        ch2->SoftLimitPos=1000000000; // clear negative soft limit
        ch2->LimitSwitchOptions=0x00000000; //clear limit switch
        Jog(2,60000); // jog quickly postitive
        while (!ReadBit(2)) ; // loop until IO bit goes high
        Jog(2,0); // stop
        while (!CheckDone(2)) ; // loop until motion completes
        Zero(2); // Zero the position
        MoveAtVel(2,-8000,70000); // move some amount inside the limits
        while (!CheckDone(2)) ; // loop until motion completes
        Jog(2,5000); // jog slowly postitive
        while (!ReadBit(2)) ; // loop until IO bit goes high
        Jog(2,0); // stop
        while (!CheckDone(2)) ; // loop until motion completes
        DisableAxis(2); // disable the axis
        EnableAxis(2); // re-enable the ServoTick
        MoveAtVel(2,-8000,50000); // move some amount inside the limits
        while (!CheckDone(2)) ; // loop until motion completes
        Zero(2); // Zero the position
        ch2->LimitSwitchOptions = SaveLimits; // restore limit settings
        ch2->SoftLimitPos = 2000; // restore negative soft limit

        // Home Y - jog until it sees the limit
        SaveLimits = ch1->LimitSwitchOptions; // save original limit settings
        ch1->SoftLimitNeg=-1000000000; // clear negative soft limit
        ch1->LimitSwitchOptions=0x00000000; //clear limit switch
        Jog(1,-60000); // jog slowly negative
        while (ReadBit(1)) ; // loop until IO bit goes high
        Jog(1,0); // stop
        while (!CheckDone(1)) ; // loop until motion completes
        Zero(1); // Zero the position
        MoveAtVel(1,8000,60000); // move some amount inside the limits
        while (!CheckDone(1)) ; // loop until motion completes
        Jog(1,-10000); // jog slowly negative
        while (ReadBit(1)) ; // loop until IO bit goes high
        Jog(1,0); // stop
        while (!CheckDone(1)) ; // loop until motion completes
        DisableAxis(1); // disable the axis
        EnableAxis(1); // re-enable the ServoTick
        MoveAtVel(1,5000,50000); // move some amount inside the limits
        while (!CheckDone(1)) ; // loop until motion completes
        Zero(1); // Zero the position
        ch1->LimitSwitchOptions = SaveLimits; // restore limit settings
        ch1->SoftLimitNeg = -2000; // restore negative soft limit

        // Home X - jog until it sees the limit
        SaveLimits = ch0->LimitSwitchOptions; // save original limit settings
        ch0->SoftLimitNeg=-1000000000; // clear negative soft limit
        ch0->LimitSwitchOptions=0x00000000; //clear limit switch
        Jog(0,-70000); // jog quickly negative
        while (!ReadBit(0)) ; // loop until IO bit goes high
        Jog(0,0); // stop
        while (!CheckDone(0)) ; // loop until motion completes
        Zero(0); // Zero the position
        MoveAtVel(0,8000,70000); // move some amount inside the limits
        while (!CheckDone(0)) ; // loop until motion completes
        Jog(0,-10000); // jog slowly negative
        while (!ReadBit(0)) ; // loop until IO bit goes high
        Jog(0,0); // stop
        while (!CheckDone(0)) ; // loop until motion completes
        DisableAxis(0); // disable the axis
        EnableAxis(0); // re-enable the ServoTick
        MoveAtVel(0,5000,50000); // move some amount inside the limits
        while (!CheckDone(0)) ; // loop until motion completes
        Zero(0); // Zero the position
        ch0->LimitSwitchOptions = SaveLimits; // restore limit settings
        ch0->SoftLimitNeg = -2000; // restore negative soft limit
    }

}

 

Group: DynoMotion Message: 10259 From: adatesman Date: 10/6/2014
Subject: Re: I did something stupid, and now it doesn't work
Nevermind, unplugging the Kflop and plugging it back in fixed the problem. No idea what happened, as all I was doing was tweaking the thread 2 homing sequence.  Got to the point that even in the Gcode screen in Kmotion it would give a "G Code Error, Axis Disabled" error, even though none of the active axes toggled to disabled.  I have a screenshot of the error, but dunno how to post it here.
Group: DynoMotion Message: 10262 From: Tom Kerekes Date: 10/7/2014
Subject: Re: I did something stupid, and now it doesn't work
One thing I noticed is that the axes should be enable only after the axes are configured not before.

Regards
TK